package com.yanqu.road.server.cmd.activity.condition;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FireWorkProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.condition.ConditionActivity;
import com.yanqu.road.server.manager.activity.condition.ConditionMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C2_CONDITION_ACTIVITY_UPDATE, desc = "更新玩家condition")
public class CrossUpdateConditionCmd extends CrossCommand {

    private int activityId;

    FireWorkProto.CrossUpdateUserConditionReqMsg reqMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = FireWorkProto.CrossUpdateUserConditionReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ConditionActivity activity = ConditionMgr.getConditionActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_ACTIVITY_NO_FOUND;
            return;
        }

        activity.updateData(serverId, reqMsg);
    }

    @Override
    public void sendData() {
        if(ret != 0){

        }
    }

}
